<?php
class Wee_Logging_Model_Archive_Collection extends Varien_Data_Collection_Filesystem{
    protected $_allowedFilesMask = '/^[a-z0-9\.\-\_]+\.csv$/i';
    public function __construct(){
        parent :: __construct();
        $basePath = Mage :: getModel('wee_logging/archive') -> getBasePath();
        $file = new Varien_Io_File();
        $file -> setAllowCreateFolders(true) -> createDestinationDir($basePath);
        $this -> addTargetDir($basePath);
    }
    protected function _generateRow($filename){
        $row = parent :: _generateRow($filename);
        $date = new Zend_Date(str_replace('.csv', '', $row['basename']), 'yyyyMMddHH', Mage :: app() -> getLocale() -> getLocaleCode());
        $row['time'] = $date;
        $dateWithoutHours = new Zend_Date(str_replace('.csv', '', $row['basename']), 'yyyyMMdd', Mage :: app() -> getLocale() -> getLocaleCode());
        $row['timestamp'] = $dateWithoutHours -> toString('yyyy-MM-dd');
        return $row;
    }
    public function filterCallbackIsMoreThan($field, $filterValue, $row){
        $rowValue = $row[$field];
        if ($field == 'time'){
            $rowValue = $row['timestamp'];
        }
        return $rowValue > $filterValue;
    }
    public function filterCallbackIsLessThan($field, $filterValue, $row){
        $rowValue = $row[$field];
        if ($field == 'time'){
            $rowValue = $row['timestamp'];
        }
        return $rowValue < $filterValue;
    }
}